﻿@{
    ViewBag.Title = "MenuCatalogEdit";
}
@using KingsSharp.Common.Extensions;
@model CRM.Admin.Contracts.Dto.Sys.MenuCatalogDto
@section head
{
    <script src="@Url.Content("~/ScriptPlugin/validate/validate.js")"></script>
    <link href="@Url.Content("~/ScriptPlugin/validate/validate.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/Scripts/form2json.js")"></script>
    <script src="@Url.Content("~/ScriptPlugin/color-spectrum/spectrum.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/ScriptPlugin/color-spectrum/jquery.spectrum-zh-cn.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/ScriptPlugin/color-spectrum/spectrum.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/App_Themes/default/icons/iconcontent/iconfont.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function SaveData(index)
        {
            if (K.Validate())
            {
                var dto=form2Json();
                KingsSharp.AjaxJson("@Url.Content("~/Sys/Menu/MenuCatalogUpdate")",{ dtos: dto }, function (result) {
                   parent.K.layer.callback(index, result,dto);
                   parent.K.layer.close(index);
                });
            }
        }
    </script>
}
<form action="">
    <div class="content-form">
        <table class="content-table">
            <tr>
                <th><span>目录名称</span></th>
                <td>
                    <input type="text" data-validate-option="isNull" id="Name" name="Name" value="@Model.Name" />
                    <input type="hidden" id="Id" name="Id" value="@Model.Id" />
                </td>
                <th>上级目录</th>
                <td>
                    <input type="text" value="@Model.PName" id="PName" name="PName" readonly="readonly" />
                    <input type="hidden" id="Pid" name="Pid" value="@Model.Pid" />
                </td>
            </tr>
            <tr>
                <th><span>目录类别</span></th>
                <td>
                    <select id="Type" name="Type" disabled="disabled">
                        <option></option>
                        @{
                            string options = "";
                            typeof(SystemMenuType).Each((name, value, description) =>
                            {
                                if (Model.Type == int.Parse(value))
                                {
                                    options += "<option selected=\"selected\" value=\"" + value + "\">" + description + "</option>";
                                }
                                else
                                {
                                    options += "<option value=\"" + value + "\">" + description + "</option>";
                                }
                            });
                        }
                        @MvcHtmlString.Create(options)
                        @*<option value="0">物业系统总公司菜单</option>
                            <option value="1">物业系统项目菜单</option>
                            <option value="99">后台系统菜单</option>*@
                    </select>
                </td>
                <th>排序号</th>
                <td>
                    <input type="text" id="Order" value="@Model.Order" name="Order" onkeypress="KingsSharp.OnlyNum();" />
                </td>
            </tr>
            <tr>
                <th>目录图标</th>
                <td>
                    <input type="hidden" id="IconText" name="IconText" value="@Model.IconText" />
                    <div style="width:20px;height:20px;float:left;font-size:24px;">
                        <i id="tIconText" style="vertical-align:top;font-size:24px;margin-top:5px;padding:0;line-height:24px;color:@Model.IconColor" class="icon iconfont">@MvcHtmlString.Create(Model.IconText)</i>
                    </div>
                    <button type="button" onclick="getIcon()" class="u-btn u-btn-c4" style="height:22px;line-height:22px;float:right;">选择...</button>
                </td>
                <th>图标颜色</th>
                <td>
                    <input type="text" value="@Model.IconColor" id="IconColor" name="IconColor" />
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding:1px 1px 0px 1px;vertical-align:top">
                    <div class="remark">
                        <div>1、当上级目录不为空时，目录类别将无法选择，自动根据上一级目录类别而产生。</div>
                        <div>2、菜单目录添加后将无法删除。</div>
                        <div>3、编辑时只允许编辑名称与图标、颜色。</div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>
@section foot
{
    <script type="text/javascript">
        function getIcon() {
            K.layer.iframe({
                title: "图标选择",
                initfull: false,
                content: "@Url.Content("~/Public/Icon")",
                area: ["440px", "395px"],
                callback: function (data) {
                    $("#tIconText").html(data.code);
                    $("#IconText").val(data.code);
                }
            });
        }
        $("#IconColor").spectrum({
           color: "@Model.IconColor",
           preferredFormat: "hex",
           showInput: true,
           change:function(color){
            $("#tIconText").css("color",color.toHexString());
           }
        });
    </script>
}